package cn.funeralobjects.upms.repository;

import cn.funeralobjects.common.repository.*;
import cn.funeralobjects.upms.entity.EUserCertificate;
import cn.funeralobjects.upms.enums.UserCertificateType;

import java.util.List;
import java.util.Optional;

/**
 * @author FuneralObjects
 * Create date: 2020/6/3 2:59 PM
 */
public interface UserCertificateRepository extends
        EntityRepository<EUserCertificate, Integer>,
        DelSaltRepository<EUserCertificate, Integer>,
        EnableRepository<EUserCertificate, Integer>,
        CodeRepository<EUserCertificate, Integer>,
        CommitRepository<Integer> {
    boolean existsAllByTypeAndCertAndDelSalt(UserCertificateType type, String cert, Integer delSalt);

    boolean existsAllByTypeAndCertAndDelSaltAndIdNot(UserCertificateType type, String cert, Integer delSalt, Integer id);

    Optional<EUserCertificate> findFirstByTypeAndCertAndDelSalt(UserCertificateType type, String cert, Integer delSalt);

    List<EUserCertificate> findAllByUser_IdAndDelSalt(Integer userId, Integer delSalt);
}
